<template>
	<el-container direction="vertical">
		<SearchForm :columns="formColumn" @search="search" @reset="search" />
		<el-header>
			<div class="left-panel">
				<el-button icon="el-icon-download">导出</el-button>
			</div>
		</el-header>
		<el-main class="nopadding">
			<scTable
				ref="table"
				tableName="studentList"
				v-bind="list"
				row-key="id"
				stripe
				:vritualData="vritualData"
			>
				<el-table-column type="selection" width="50"></el-table-column>
				<template #type="scope">
					<el-link
						type="primary"
						:underline="false"
						:href="`#/student/info/detail/${scope.row.id}`"
						>{{ scope.row.type }}</el-link
					>
				</template>
				<template #subType="scope">
					<el-link
						type="danger"
						:underline="false"
						:href="`#/student/info/detail/${scope.row.id}`"
						>{{ scope.row.subType }}</el-link
					>
				</template>
				<template #memory="scope">
					<el-link
						type="danger"
						:underline="false"
						:href="`#/student/info/detail/${scope.row.id}`"
						>{{ scope.row.subType }}</el-link
					>
				</template>
				<!-- oprateGraduation -->
				<!-- <template #oprateGraduation="{row}">
					<el-button
						plain 
						size="small"
						@click="gratuationApplicate(row.id)"
					>毕业申请</el-button>
				</template> -->
				<el-table-column
				label="操作"
				fixed="right"
				align="center"
				width="220"
			>
				<template #default="{row}">
					<el-button
						plain 
						size="small"
						@click="gratuationApplicate(row.studentId)"
					>毕业申请</el-button>
				</template>
			</el-table-column>
			</scTable>
		</el-main>
	</el-container>
</template>

<script>
import SearchForm from "@/components/SearchForm/index.vue";
import { formColumn, column } from "./data";

export default {
	components: {
		SearchForm,
  },
  emits: ['toGraduationDetail'],
	data() {
		return {
			formColumn,
			list: {
				apiObj: this.$API.student.graduate,
				params: {
					studentId: parseInt(this.$route.params.id)
				},
				column,
			},
			vritualData: [
				{studentName: "222323", studentId:parseInt(this.$route.params.id)}
			]
		};
	},
	methods: {
		search(searchParams) {
			let params = {}
			if(searchParams) {
				const searchObj = JSON.parse(JSON.stringify(searchParams))
				params = Object.assign({}, searchObj, this.list.params)
			}else{
				params = Object.assign({}, this.list.params, {});
			}
			this.$refs.table.reload(params);
    },
    gratuationApplicate(studentId) {
			this.$router.push({
				path: `/student/detail/graduationApplication/${studentId}`
			})
    }
	},
};
</script>

